package main

//注释
/*
ver: golang 1.1.0+
*/

import (
	"fmt"
)

func mute(a ...interface{}) {
}

func vari() {
	println("变量常量")
	a := 1
	f := 0.1
	var c interface{}

	a = 2
	c = nil
	mute(a, f, c)
}

func stri() {
	println("字符串")
	s := fmt.Sprintf("ab%s\n", "test")

	mute(len(s))
}

func coll() {
	println("数组集合")
	arr := [2]string{"1", "2"}
	list := []int{1, 2}
	set := map[string]bool{}
	mp := map[string]int{}

	list = append(list, 3)
	set["a"] = true
	mp["a"] = 1

	for idx, ele := range arr {
		mute("idx %d ele %s", idx, ele)
	}
	for key, val := range mp {
		mute("key %s val %s", key, val)
	}
}

func proc() {
	println("流程控制")
	var a = 1
	if a == 1 {
		a = 2
	}

	var obj interface{}

	switch obj {
	case 1, 2:
		mute(1)
	case 3:
		mute(3)
	default:
		mute(0)
	}

	for i := 0; i < 3; i++ {
		mute(i)
	}
	for {
		break
	}
}

func fun() {
	println("函数")
	add := func(a, b int) int {
		return a + b
	}
	add(1, 2)
}

func clas() {
	println("类和对象")
	type A struct {
		v int
		V int
	}

	a := A{}
	mute(a)
}

func othe() {
	println("其它")
}

type B struct {
	b int
}
type C struct {
	B
	c int
}

func NewB() (this *B) {
	this = &B{}
	return
}

func (this *B) bf() error {
	mute()
	return nil
}

func main() {
	fmt.Printf("Hello, World!\n")
	vari()
	stri()
	coll()
	proc()
	fun()
	clas()
	othe()
}
